package com.zjitc.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Create By IntelliJ IDEA
 *
 * @author: myq
 * @create-Time: 2017/11/30  11:59
 */
public class AlipayConfig {

    //↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "2016082700322240";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQClz+q/CnHhYgX+W3ig7YHTaHnrQeTJNKB3eLFH8J9ZGKzs0Chj5XUfznuknJicEB3+PqoDi0U0GO2nrsv3unEYzO3JyacZMPceq9gnMii4qS7un8QVq7QU71nu4z7YcWMLo8W8d4kUeFC0bcrypXvNU60mi2Nl7vE/SREMbmmW4xNs//M4fsehiTrmPW1OjfK4dbYOP9xni1Goytq5JR8tktz1iREezv2i37No7jX+Eo+DiBxKv9MAo+qNY5QN/du+akfIZLJSYNUOC/RFRrsus0aZC9fNOlXaso8c+glxFvKxANKfSXrYtKcqDGtJF6wV+Vganb+kN8+bjxChny4TAgMBAAECggEAXPTsML/lSiqPG6MiRG4Ce4e12gst/RLw5ymVkbQ3UVbBE147Vo28FOHIdWeJMuziM7fjzmrUmDller1HAhHW98Vjhd30PO4zjFFgs9Ct/aBzfDm7Tz7cjWQGMiPaBrPCiDL/VwJYqk4tSInI3jGh72F60AIS7oF/ZDBNS3/W2Ex8Slpy/F71Ti+o9Yg/WXR2vMpVV6cBYRt57zslQwzHyZ5T8hLbpA16tUo8evllyJufni3QkEIRwsUDe7ELwhBe7Oj5qvWKskQ6xqaxL+nKy9bKK0VuU0QblTiLCWR5RZ3qRf9Iy5Z85h1VlAAB1h1+qJJf1i/IW4Pz7njfiSKcWQKBgQDXV0DgC1PVAFe7gdlJt19q/xdU/TqVRfd9e6yCGCEkuRI6W1BLaAScok2s1GOLkSOTCZtAoX90eyYS7a/8EiURGweyem9bmnjt0TepnaPWmR1R6pjGInNnykH81lhbbq5gKjUvyOghH/xgYAf2JZ98zZydl+w2hwbPn3xhIIt0FQKBgQDFHqOT+bnGF1Z5Ynk+t8VdjckGl1IKa74Z/NMs4KFaDldjs8fXibrJcU0U/OsmKGO25Cws3ny3XhybOtyEztPi6WWsP+VmKP32cuxUzzvdGLwMUMAwtAxNJJ/PgGBRcWcMFeTf4BPL8hqnz9otwrpLtdv6B/QJ1w814j6/y2vbhwKBgFJgx6mty6ktU2Kg3u3rX25AHb3ejb2zIWV4nVq7PlqdDhMTAZmHNlRxZoOaUGaA5HoIb8L+xRJbVgphsTQeAN4VWBF38we5BU/8/G0/qACdXHEM7NrHLRzka+/8U5rOsZiKLQSVt++MG/EGa6VHaUbGJYbIKo4Fg56DpYJGf/KtAoGBAK5UcoakDNBMQ4YGuQPmsv4SLv9NRJlCwFVra7f80bY7iL38eXj9rdwKAAnXxH9yqP1OvmLQQaxJ5zLB09UAthOwJuM3f0HibvhOmwRGYsMe5PBfWhm4okh3Y364InbkvCXMFyaHnfp4m2peQK7H0Mq0g1+VORaaxDD7blNhLHpxAoGAZAgM+mceHb7Bhm7nmsZ5tHJbKHnl/8fVy5vON7mNoLIKF59fVgtdQj1t6wLPls6qAas4sYgXfsHbSJipEwjuJM3+kI8x8y+5ketZBj/E4aDm5W0jHuAMx6qntamTnGwKV37tKbRlh/bftD6xo1UtJe1l97zak0hMM4Ky+xaoPW8=";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuyxb6dWvTKeU88cMPKkq2vYbgULCfxL7/+W2qbCwrEFzQdiIiJGeEKj1j9EyBoJr5+TW5odGMxMqgnea8MWk2/WGb0AjWQQvAaZz7zTqpY6m90YOjwIS3lZFQqkBP3b1xOicsdbFNPMZ7YptHufhqhXiocAm9NM/ZfisNN7/a7leHDP6TIwOGSB0mzQ+4ijdf+VY7eRWIMaOX4E2XX6rpsUj8WlDVUT2cXUSXaRMKJ+TAJeuxNOu6FaNgurbBjxqaiRTVb6dpRk/uTRLFWXf8LJ1seZ6k2rfxpO1vtC/nu6j16mNRsw/wrpPZLbcKgO4i5ODb/N2wbEF/Lgdr1jwNwIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    //public static String notify_url = "http://localhost:8080/notify_url.jsp";
    public static String getNotify_url(HttpServletRequest request, HttpServletResponse response){
        String path = request.getContextPath();
        String url = "http://localhost:8080" + path + "/notify_url.jsp";
        return url;
    }

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String return_url = "http://localhost:8080/return_url.jsp";
    public static String getReturn_url(HttpServletRequest request, HttpServletResponse response){
        String path = request.getContextPath();
        String url = "http://localhost:8080" + path + "/return_url.jsp";
        return url;
    }

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
